%{
#include <stdio.h>
#include <string.h>

#include "y.tab.h"
extern char * yylval;

#define YYSTYPE     char *
#define YY_NO_UNPUT 1

void yyerror(const char *msg)
{
    (void)fprintf(stderr, "error: %s at '%s'\n", msg, yytext);
}

%}

eol         \n
space       [ \t]+
comment     #.*
qstring     \"[^\"\n]*[\"\n]
word        [a-zA-Z][a-zA-Z0-9-]*
num         [0-9-][0-9]*

%%
{comment}                                                   {
                                                            }

{space}                                                     {
                                                            }

{eol}                                                       {
                                                            }

{qstring}                                                   {
                                                            yylval=strdup(yytext+1);
                                                            yylval[yyleng-2] = '\0';
                                                            return WORD;
                                                            }

{word}                                                      {
                                                            yylval=strdup(yytext);
                                                            return WORD;
                                                            }

{num}                                                       {
                                                            yylval=strdup(yytext);
                                                            return NUMBER;
                                                            }

=                                                           {
                                                            return EQUALS;
                                                            }

^\[                                                         {
                                                            return OBRACKET;
                                                            }

\][ \t]*$                                                   {
                                                            return EBRACKET;
                                                            }
%%
